/**
 * 
 */
var oTable;
$(function(){
	//初始化
	initDataTable();
	
	$('#search').click(function(){
		oTable.ajax.reload();
	});
});

function initDataTable(cid, ds, ipcc) {
	oTable = $('.example').DataTable({
		"dom": '<"top">rt<"bottom"ip><"clear">',
		"ajax": {
			"type": "POST",
			"url": "ipcclist.ajax",
			"data": function(d) {
				d.cid = $('#cid').val(),
				d.ds = $('#ds').val(),
				d.ipcc = $('#ipcc').val();
			}
		},
		"ordering": false,
		"aLengthMenu": [5, 10, 20, 40 ],
		"iDisplayLength" : 10,
		"oLanguage": {
			"sUrl": "static/js/datatable.cn.txt"
		},
		"aoColumns": [
			{"mDataProp":"id"},
			{"mDataProp":"cname"},
			{"mDataProp":"ds"},
			{"mDataProp":"ipcc"},
			{"mDataProp":"status"},
			{"mDataProp":"temp"},
			{"mDataProp":"temp1"},
			{"mDataProp":"op"},
			{"mDataProp": "time"}
		],
		"columnDefs": [
           {
        	   "render": function (data, type, row) {
        		   if(row.status == "1") {
        			   return '<span>已开启&nbsp;&nbsp;</span><img class="showImg" alt="Brand" src="static/images/u165.png" width="40" height="40">';
        		   } else {
        			   return '<span>已关闭&nbsp;&nbsp;</span>';
        		   }
        	   },
        	   
        	   "targets": 5
           },
           {
        	   "render": function (data, type, row) {
        		   if(row.status == "1") {
        			  // return '<a class="btn btn-link" href="javascript:void(0);" title="设置航班投放时间" onclick="javascript:goFlight('+row.id+','+row.cname+','+row.ds+','+row.ipcc+')">设置航班投放时间</a>';
        			   return '<a class="btn btn-link" title="设置航班投放时间" onclick="javascript:goFlight('+row.id+',\''+row.cname+'\',\''+row.ds+'\',\''+row.ipcc+'\')"  href="javascript:void(0);">设置航班投放时间</a>';
        		   } else {
        			   return '<a class="btn btn-link" href="javascript:void(0);" style="text-decoration:none;color:gray;">设置航班投放时间</a>';
        		   }
        	   },
        	   
        	   "targets": 4
           },
           {
        	   "render": function (data, type, row) {
        		   if(row.status == "1") {
        			   return '<a class="btn btn-warning" href="javascript:void(0);" onclick="javascript:goSwitch(' + row.id + ',0,\''+row.cname+'\',\''+row.ds+'\',\''+row.ipcc+'\')" title="关闭IPCC">关闭</a>';
        		   } else {
        			   return '<a class="btn btn-success" href="javascript:void(0);" onclick="javascript:goSwitch(' + row.id + ',1,\''+row.cname+'\',\''+row.ds+'\',\''+row.ipcc+'\')" title="开启IPCC">开启</a>';
        		   }
        	   },
        	   
        	   "targets": 6
           },
           {
               "render": function ( data, type, row ) {
            	   return '<a class="btn btn-info" href="javascript:void(0);" onclick="javascript:goEdit(' + row.id + ')" title="编辑">编辑</a>&nbsp;&nbsp;' +
            	   		  '<a class="btn btn-danger" href="javascript:void(0);"  onclick="javascript:delConfirm(' + row.id + ')" title="删除">删除</a>';
               },
               "targets": 7
           },
           {
        	   "targets": 8,
        	   "visible": false
           }
       ]
	});
}